#pragma once
#include <iostream>
#include <vector>
#include <string>

class Util
{
    public:
    //aaaa\r\nbbbbb\r\nccc\r\n\r\n
    /******************************
     * s = 传入的字符串
     * sep = 用于分割的特殊字符
     * out = 输出型vector
    ******************************/
    static void cutString(std::string s,const std::string& sep,std::vector<std::string>* out)
    {
        std::size_t cur = 0;
        while(cur < s.size())
        {
            //      找sep这个字符串  从cur开始
            auto pos = s.find(sep,cur);
            if(pos == std::string::npos) break;   //没有分割符就直接出来
            //      从哪裁   裁多少
            std::string sub = s.substr(cur,pos-cur);
            out->push_back(sub);
            cur += sub.size();
            cur += sep.size();
        }
        if(cur < s.size()) out->push_back(s.substr(cur));
    }
};